package com.shop.cloud.service.hongfu.impl;

import com.shop.cloud.domain.hongfu.RebateHistory;
import com.shop.cloud.service.hongfu.IRebateHistoryService;
import com.shop.cloud.dao.hongfu.RebateHistoryDao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shop.cloud.common.mybatis.BaseService;
import com.shop.cloud.common.mybatis.MybatisDao;

/**
 * 
 */
@Service("rebateHistoryService")
public class RebateHistoryService extends BaseService<RebateHistory> implements IRebateHistoryService{
    
    @Autowired
	private RebateHistoryDao rebateHistoryDao;

	@Override
	public MybatisDao<RebateHistory> getEntityDao() {
		return rebateHistoryDao;
	}

	@Override
	public RebateHistory handleRebateYearAndMonth(Long userId) {
		List<Integer> yearList = new ArrayList<Integer>();
		
		RebateHistory rebateHistory = new RebateHistory();
		rebateHistory.setUserId(userId);
		
		RebateHistory min = rebateHistoryDao.getMinYearAndMonth(rebateHistory);
		int minYear = min.getThisYear();
		
		RebateHistory max = rebateHistoryDao.getMaxYearAndMonth(rebateHistory);
		int maxYear = max.getThisYear();
		
		for(int i = minYear; i <= maxYear; i ++){
			yearList.add(i);
		}
			
		RebateHistory result = new RebateHistory();
		result.setShowYearList(yearList);
		
		return result;
	}
    
}